package com.ss.android.article.base.feature.e;

import android.text.TextUtils;
import com.a.a.NightMode;
import com.ss.android.account.activity.aa;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.common.share.abs.AbsShareHelper;
import com.ss.android.article.common.share.log.ShareRespEntry;
import com.ss.android.common.lib.MobClickCombiner;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import org.json.JSONException;
import org.json.JSONObject;

public class h extends aa {
    public h() {

    }

    private void a(ShareRespEntry arg10, String arg11, JSONObject arg12) {
        long v0_1;
        long v4;
        String v2;
        long v6 = 0;
        if(arg10 != null && !TextUtils.isEmpty(((CharSequence)arg11))) {
            if(arg10 == null) {
                v2 = null;
            }
            else if(!TextUtils.isEmpty(arg10.eventName)) {
                v2 = arg10.eventName;
            }
            else {
                String v0 = "";
                switch(arg10.shareSource) {
                    case 199: {
                        v0 = "detail_mid_share";
                        break;
                    }
                    case 201: {
                        v0 = "list_share";
                        break;
                    }
                    case 202: {
                        v0 = "share_topic";
                        break;
                    }
                    case 203: {
                        v0 = "share_update_post";
                        break;
                    }
                    case 204: {
                        v0 = "share_topic_post";
                        break;
                    }
                    case 205: {
                        v0 = "pgc_profile";
                        break;
                    }
                    case 207: {
                        v0 = "share_topic_post";
                        break;
                    }
                    case 200: 
                    case 208: {
                        v0 = "detail_share";
                        break;
                    }
                    case 209: {
                        v0 = "share_concern";
                        break;
                    }
                    case 211: {
                        v0 = "share_answer_list";
                        break;
                    }
                    case 212: {
                        v0 = "share_live_chat";
                        break;
                    }
                    case 213: {
                        v0 = "list_share";
                        break;
                    }
                }

                v2 = v0;
            }

            if(arg10 == null) {
                v4 = v6;
            }
            else {
                switch(arg10.shareSource) {
                    case 203: 
                    case 204: {
                        v0_1 = arg10.updateId;
                        break;
                    }
                    case 205: {
                        v0_1 = arg10.pgcId;
                        break;
                    }
                    case 209: {
                        v0_1 = arg10.m;
                        break;
                    }
                    case 211: {
                        v0_1 = arg10.n;
                        break;
                    }
                    case 212: {
                        v0_1 = arg10.l;
                        break;
                    }
                    case 199: 
                    case 200: 
                    case 201: 
                    case 213: {
                        v0_1 = arg10.groupId;
                        break;
                    }
                    default: {
                        v0_1 = v6;
                        break;
                    }
                }

                v4 = v0_1;
            }

            if(arg10 != null) {
                switch(arg10.shareSource) {
                    case 199: 
                    case 200: 
                    case 201: {
                        v6 = arg10.adId;
                        break;
                    }
                    default: {
                        break;
                    }
                }
            }

            MobClickCombiner.onEvent(this, v2, arg11, v4, v6, arg12);
        }
    }

    private static void a(String arg4, String arg5, JSONObject arg6) {
        if(!android.support.design.a.isTextEmpty(arg4)) {
            String v0 = arg6.optString("source");
            String v1 = arg6.optString("category_name");
            if(v0.equals("headline")) {
                v0 = "click_headline";
            }
            else if(v0.equals(v1)) {
                v0 = "click_category";
            }
            else {
                v0 = "click_" + v0;
            }

            try {
                arg6.remove("source");
                arg6.put("share_platform", arg5);
                arg6.put("enter_from", v0);
                arg6.put("category_name", v1);
                if(!AppData.getInstance().getAbSettings().isApplogStaging()) {
                }else {
                    arg6.put("_staging_flag", 1);
                }
            }
            catch(JSONException v0_1) {
            }

            android.support.design.a.onEvent(arg4, arg6);
        }
    }

    public void onReq(BaseReq arg1) {
        if(arg1 != null) {
            super.onReq(arg1);
            arg1.getType();
        }
    }

    public void onResp(BaseResp arg9) {
        String v2_1;
        String v1_2;
        JSONException v1;
        JSONObject v0_2;
        android.support.design.a v3 = null;
        if(arg9 != null) {
            super.onResp(arg9);
            int v0 = arg9.getType();
            ShareRespEntry v4 = AbsShareHelper.entry;
            if(v4 == null) {
                return;
            }

            if(v0 != 2) {
                return;
            }

            try {
                if(v4.extJsonObj == null) {
                    v4.extJsonObj = new JSONObject();
                }

                v4.extJsonObj.put("group_id", v4.groupId);
                v4.extJsonObj.put("title", v4.title);
                v4.extJsonObj.put("gtype", v4.gtype);
                v4.extJsonObj.put("item_id", v4.itemId);
                v0_2 = new JSONObject(v4.extJsonObj.toString());
                v0_2.put("weixin_share_error_code", arg9.errCode);
            }
            catch(JSONException v0_1) {
                v1 = v0_1;
                v0_2 = null;
                v1.printStackTrace();
            }
            int v1_1 = arg9.errCode == 0 ? 1 : 0;
            boolean v2 = AppData.getInstance().isShareExtendedObjectEnabled();
            if(v4.shareType != 0) {
                if(v2) {
                    v1_2 = v1_1 != 0 ? "share_weixin_moment_extend_done" : "share_weixin_moment_extend_fail";
                    this.a(v4, v1_2, v0_2);
                }else {
                    v2_1 = v1_1 != 0 ? "share_weixin_moment_done" : "share_weixin_moment_fail";
                    this.a(v4, v2_1, v0_2);
                    v1_2 = v1_1 != 0 ? "share_to_platform_success" : "share_to_platform_fail";
                    h.a(v1_2, "weixin_moments", v0_2);
                }
            }
            else if(v2) {
                v1_2 = v1_1 != 0 ? "share_weixin_extend_done" : "share_weixin_extend_fail";
                this.a(v4, v1_2, v0_2);
            }
            else {
                v2_1 = v1_1 != 0 ? "share_weixin_done" : "share_weixin_fail";
                this.a(v4, v2_1, v0_2);
                v1_2 = v1_1 != 0 ? "share_to_platform_success" : "share_to_platform_fail";
                h.a(v1_2, "weixin", v0_2);
            }

            m.a = v3;
            com.ss.android.article.share.d.h.b = ((NightMode)v3);
            AbsShareHelper.entry = ((ShareRespEntry)null);
        }
    }
}

